﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKSparseDistance.ControlLayer;
using YJKRoomInspection.ProgramArchitecture;
using YJKRoomInspection.Utiltiy;
using YArchitech.Controls;
using YJKRevitBase.WinForm;
using YJKRevitView;
using YJKInspectModelFunc;

namespace YJKSparseDisOfDoor.ControlLayer
{
	public class TempleCmd
	{
		public void Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			try
			{
				StaticRescource.IfHasUse = true;
				UIApplication application = commandData.Application;
                Autodesk.Revit.ApplicationServices.Application application2 = application.Application;
				Document document = application.ActiveUIDocument.Document;
				StaticRescource.CmdData = commandData;
				IntPtr mainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
				IWin32Window inputRevitHandle = new WindowHandle(mainWindowHandle);
				StaticRescource.m_hWndRevit = new WindowHandle(mainWindowHandle);
				List<Level> list = new List<Level>();
				if (FloorSelectManager.SelectFloorLevels(document, ref list))
				{
					StaticRescource.m_SelectLevels = list;
					YJKInspectModelFunc.Utility.AddRoomToNoneRoomPlace(document, list);
					new FrontRoomArch(application, new AppendCheckArch(), commandData, list, inputRevitHandle).IfNeedYJKRoomInspection(document, list);
					YJKInspectModelFunc.Utility.DeleteAddRoom(document, PublicYJKRoomInspection.LstFrontRoomIds);
				}
			}
			catch (Exception ex)
			{
				YJKMessageBox.Show("出现错误" + ex.Message);
			}
		}
	}
}
